package com.tuanzi.loan.web.bean.galaxycard;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.tuanzi.loan.business.entity.system.SystemUser;
import com.tuanzi.loan.business.service.galaxycard.GalaxyCardPromoteChannelUserRightService;
import com.tuanzi.loan.business.service.system.SystemUserService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.galaxycard.GalaxyCardPromoteChannelUserRightRequest;
import com.tuanzi.loan.vo.response.galaxycard.GalaxyCardPromoteChannelUserRightResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.galaxycard.GalaxyCardPromoteChannelUserRightLazyDataModel;

/**
 * 银河黑卡外推渠道用户权限管理后台Bean
 * @author chenweijun 2018/01/30
 *
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class GalaxyCardPromoteChannelUserBean extends JSFListingBean<GalaxyCardPromoteChannelUserRightRequest, GalaxyCardPromoteChannelUserRightResponse> {
	
	private static final long serialVersionUID = -2108423002836338325L;
	
	private List<SystemUser> galaxyCardPromoteUserList;
	
	@Autowired
	private GalaxyCardPromoteChannelUserRightService galaxyCardPromoteChannelUserRightService;
	
	@Autowired
	private SystemUserService systemUserService;
	
	@PostConstruct
	private void init() {
		initLazyDataModel();
		galaxyCardPromoteUserList = systemUserService.findAllByRoleCode("GALAXYCARDPARTNER");
	}
	
	private void initLazyDataModel() {
		$ = new GalaxyCardPromoteChannelUserRightRequest();
		lazyDataModel = new GalaxyCardPromoteChannelUserRightLazyDataModel($);
	}
	
	public String onEdit(String userId) {
        return redirect("/views/galaxycard/galaxy-card-promote-channel-user-right-info.xhtml?userId=" + userId);
    }
	
	
	public String onRelateChannel(String userId) {
        return redirect("/views/galaxycard/galaxy-card-promote-channel-user-right-info.xhtml?userId= " + userId);
    }
	
}
